
###########################################################################
#                                                                         #
#  SConstruct -- DSPI Example SCONS Build Script                          #
#                                                                         #
###########################################################################
#  Author: MTA                                                            #
#  Copyright 2010 Digilent Inc.                                           #
###########################################################################
#  File Description:                                                      #
#                                                                         #
#  This is a SCONS build script for the DSPI Example project. This script #
#  can be used to build the project on a Linux system. The script allows  #
#  for specification of whether or not a debug or release build is        #
#  performed.                                                             #
#                                                                         #
#  Command line options:                                                  #
#                                                                         #
#    Option   | Supported Values | Description                            #
#  ---------------------------------------------------------------------- #
#    release  | 0 (default)      | create a debug build                   #
#             | 1                | create a release build                 #
#                                                                         #
#  Command line options are specified in the form of "option=value". If   #
#  an option isn't specified when the script is invoked then the default  #
#  value is used. The following shows two different ways to perform a     #
#  a debug build.                                                         #
#                                                                         #
#  "scons"                                                                #
#  "scons release=0"                                                      #
#                                                                         #
#  Please note that the files generated by this build script will be      #
#  output in the directory that the script resides in.                    #
#                                                                         #
#  In addition to compiling, linking, and outputing files, SCONS can also #
#  be used to clean up the output generated by a build when it is no      #
#  longer needed. If "scons release=1" is the command used to invoke the  #
#  script for a build then invoking the script again with                 #
#  "scons release=1 -c" will clean the output directories and remove all  #
#  intermediate files that were used to generate the output.              #
#                                                                         #
###########################################################################
#  Revision History:                                                      #
#                                                                         #
#  08/10/2010(MTA): created                                               #
#                                                                         #
###########################################################################

# Get any command line options that were specified when the script was
# invoked. The second value is specified as the default if an option
# wasn't specified when the script was invoked.
release = ARGUMENTS.get('release', '0')


# Set the include path. This is the directory that will be searched for
# header files that can't be found in the standard locations. We need to
# specify the directory that contains the header files for the Adept SDK.
# Please note that it may be necessary to change this path depending on
# where you installed the Adept SDK include files.
incpath = ['/usr/local/include/digilent/adept']


# Declare the search path used for shared libraries that can't be found
# in standard locations. We need to specify the directory that contains
# the Adept Runtime shared libraries in order to link with them. Please
# note that it may be necessary to change this path depending on where
# you installed the Adept Runtime shared libraries.
libpath = ['/usr/local/lib/digilent/adept']


# Create an array containing the compiler flags used for all builds.
ccflags = ['-Wall', '-Wextra']


# Create an array containing the preprocessor definitions for all builds.
cppdefines = []


# Determine if we are performing a debug build or a release build.
if ( release == '0' ):
    # Debug build
    
    ccflags.append('-g') # Generate debug symbols
    cppdefines.append('_DEBUG')


# Create the environment used for compiling and linking.
env = Environment(CPPDEFINES = cppdefines, CCFLAGS = ccflags)

    
# The include path (incpath) needs to be appended to the CPPPATH
# construction variable, which tells the C preprocessor where to search for
# include directories. Please note that this needs to be appeneded to the
# CPPPATH construction variable so that the system default include
# directories aren't excluded.
env.Append(CPPPATH=incpath)


# Define a list of libraries that the application must link against.
libs = ['dmgr', 'dspi']


# Create a list of source files to pass to the compiler.
sources = [Glob('*.cpp')]


# Build the application.
env.Program('DspiDemo', sources, LIBS=libs, LIBPATH=libpath)

